export default {
  formatDate(date) {
    let time = new Date(date)
    return `${time.getFullYear()}年${time.getMonth() + 1}月${time.getDate()}日`;
  },

  formatTimeStamp(timeStamp) {
    let d = new Date(Number(timeStamp));
    // let batchDate = d.getFullYear() + '年' + (d.getMonth() + 1) + '月' + d.getDate() + '日'
    let batchTime = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
    // + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
    return batchTime
  },

  formatDateTime(dateTime) {
    let d = new Date(dateTime);
    let batchTime = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
    return batchTime
  },
  // 时间转字符串，转成yyyy-MM-dd HH:mm:SS格式
  dateToStr(datetime) {
    var dateTime = new Date(datetime);
    var year = dateTime.getFullYear();
    var month = dateTime.getMonth() + 1; //js从0开始取
    var date = dateTime.getDate();
    var hour = dateTime.getHours();
    var minutes = dateTime.getMinutes();
    var second = dateTime.getSeconds();

    if (month < 10) {
      month = "0" + month;
    }
    if (date < 10) {
      date = "0" + date;
    }
    if (hour < 10) {
      hour = "0" + hour;
    }
    if (minutes < 10) {
      minutes = "0" + minutes;
    }
    if (second < 10) {
      second = "0" + second;
    }

    // return year + "-" + month + "-" + date + " " + hour + ":" + minutes + ":" + second;
    return year + "-" + month + "-" + date
  },
  getAuthorization() {
    let token = window.sessionStorage.getItem('token');
    return token
  },
}